home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c++ / 652 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  1.9 KB

  1. From: clamage@Eng.Sun.COM (Steve Clamage)
  2. Message-ID: <4hkean$mrc@engnews1.Eng.Sun.COM>
  3. X-Original-Date: 6 Mar 1996 16:25:59 GMT
  4. Path: in1.uu.net!bounce-back
  5. Date: 07 Mar 96 13:40:54 GMT
  6. Approved: fjh@cs.mu.oz.au
  7. Newsgroups: comp.std.c++
  8. Subject: Re: Streams and eof()
  9. Organization: Sun Microsystems Inc.
  10. References: <4hgap6$6o7@fu-berlin.de>
  11. Reply-To: clamage@Eng.Sun.COM
  12. X-Auth: PGPMoose V1.1 PGP comp.std.c++
  13.     iQBFAgUBMT7ncuEDnX0m9pzZAQHhvQF/XVgxMOoiU7qCdMkaSZeYb5JlvoUBLtrx
  14.     xbrwrBjnZgsGHxwjaomy7MzADE9Bd2zM
  15.     =+p2N
  16.  
  17. In article 6o7@fu-berlin.de, axl@zedat.fu-berlin.de (Axel Thimm) writes:
  18.  
  19. >kanze@gabi-soft.fr (J. Kanze) wrote:
  20.  
  21. >>You might want to try the function `peek'.  I tend to use this function
  22. >>a lot.  Basically, this forces a look-ahead, which will set the eof if
  23. >>there is nothing more there.
  24.  
  25. >But I think that you can use this only with text streams, not with
  26. >binary streams (You would not be able to tell a eof-char from an
  27. >ordinary binary char).
  28.  
  29. No, it must work. EOF is required to have a value different from every
  30. character value. The character-reading functions that can return either
  31. a character or EOF return a type that that can represent the EOF value
  32. as distinct from any character value.
  33.  
  34. In a traditional implementation, EOF has the int value -1, and characters
  35. have 8-bit values. The peek function returns the character value promoted
  36. to type int without sign extension, as if by the cast sequence
  37.     (int)(unsigned char)the_value
  38. Such a value cannot compare equal to the int value -1.
  39.  
  40. The situation is more complicated for wide characters, but the principle
  41. remains.
  42. ---
  43. Steve Clamage, stephen.clamage@eng.sun.com
  44. ---
  45. [ To submit articles: try just posting with your news-reader.
  46.                       If that fails, use mailto:std-c++@ncar.ucar.edu
  47.   FAQ:      http://reality.sgi.com/employees/austern_mti/std-c++/faq.html
  48.   Policy:   http://reality.sgi.com/employees/austern_mti/std-c++/policy.html
  49.   Comments? mailto:std-c++-request@ncar.ucar.edu.
  50. ]
  51.